Server Watch Plugin SDK Date: 6 Feb 2004
Release: 1.0
Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

DFRegTool Class Reference

#include <DFRegTool.h>

List of all members.


Detailed Description

Use this class to access the Windows registry in a Server Watch plugin. The class is designed to help abstract out the complexity of the Windows registry, and its use allows us to control the data in the registry and insulate your plugin's registry settings from changes to how the registry is handled in Server Watch.

Registry Safety
One common problem with the windows registry is that it is too easy to modify the wrong area of the registry. This class bypasses that problem by only allowing the user to operate within a strict subsection of the tree -- the applications registry space.
Required for use in Plugins
If you do not use this class to store your registry, Server Watch will not be able to update your registry values during an upgrade of Server Watch and your plugin may break or become non-backwards compatible. Use of this class is compulsory for all registry work in Server Watch.
Plugin Examples
Use this class with the strRegistryBase string defined in SWPluginServerStruct to make sure that you always save plugin data to the right place.
  // Create the registry class
  DFRegTool reg;
  
  // Open registry to the appropriate location in the registry for your plugin.
  // The m_pCurrentServer is an instance of SWPluginServerStruct that was passed
  // into the plugin.
  reg.OpenKey(m_pCurrentServer->strRegistryBase);

  // Save a string
  reg.AddStr(L"DemoString", L"DemoValue");

  // Close the key. This is optional, the instance of DFRegTool will automatically
  // close the key when the instance is destroyed.
  reg.CloseKey();


Public Member Functions

Constructor/Destructor
 DFRegTool ()
virtual ~DFRegTool ()
Opening/Closing the key
LONG OpenKey ()
LONG OpenKey (const CAtlString &)
LONG OpenKey (const std::wstring &)
LONG OpenKey (const TCHAR *)
LONG OpenKey (DWORD &)
LONG OpenKey (const CAtlString &, DWORD &)
LONG OpenKey (const std::wstring &, DWORD &)
LONG OpenKey (const TCHAR *, DWORD &)
LONG CloseKey ()
Numeric Values
LONG AddDword (LPCTSTR key, DWORD value)
Numeric Values
Stores the numeric value of the key/value pair as a simple DWORD in the registry. The variable type of the value can be retrieved as one of a many types, but the user should take care so as not to retrieve a value from the registry and put it into a variable smaller than required or the value will be truncated.

LONG GetDword (LPCTSTR key, DWORD &value)
LONG GetDword (LPCTSTR key, int &value)
LONG GetDword (LPCTSTR key, bool &value)
Basic String Values
Stores the string value of the key/value pair as a simple human readable unicode string. The variable type of the value can be one of a many types.

LONG AddStr (LPCTSTR key, LPCTSTR value)
LONG AddStr (LPCTSTR key, const CAtlString &value)
LONG AddStr (LPCTSTR key, const std::wstring &value)
LONG GetStr (LPCTSTR key, LPTSTR, DWORD value)
LONG GetStr (LPCTSTR key, CAtlString &value)
LONG GetStr (LPCTSTR key, std::wstring &value)
Encoded String
Stores the string value of the key/value pair in an encoded format. The encoding is basic and should not be considered secure. The variable type of the value can be one of a many types.

Code Numbers
The values passed into codeA and codeB when the string is set must be the same values passed into the call to GetCodedStr() to fetch the string of the value returned will not be correct.


LONG AddCodedStr (LPCTSTR key, const CAtlString &value, int codeA, int codeB)
LONG AddCodedStr (LPCTSTR key, const std::wstring &value, int codeA, int codeB)
LONG AddCodedStr (LPCTSTR key, const TCHAR *value, int codeA, int codeB)
LONG GetCodedStr (LPCTSTR key, CAtlString &value, int codeA, int codeB)
LONG GetCodedStr (LPCTSTR key, std::wstring &value, int codeA, int codeB)
Deletion
LONG DeleteContents ()
LONG DeleteFolder (LPCTSTR)
LONG DeleteKey (LPCTSTR)
Replication
LONG Replicate (const DFRegTool &)
Tree Iteration
LONG NextKey (CAtlString &strFileName, int iSetBack=0)
LONG NextKey (std::wstring &strFileName, int iSetBack=0)
LONG NextValue (CAtlString &strValueName, int iSetBack=0)
LONG NextValue (std::wstring &strValueName, int iSetBack=0)
XML Import/Export
LONG BeginExportToXML ()
LONG ExportKeyToXML (LPCTSTR szKeyName, DFRegTool &regKey)
LONG EndExportToXML (LPCTSTR szFileName)
LONG BeginImportFromXML (LPCTSTR szFileName)
LONG ImportFromXML (LPCTSTR szKeyName, CXMLReg &xmlImport)
LONG EndImportFromXML ()
CXMLReg * GetXMLImporter ()
CXMLReg * GetXMLExporter ()

Protected Types

enum  FetchType { Readable, Encoded, Whole }

Protected Member Functions

LONG DeleteHelper (HKEY hParentKey)
LONG ExportHelper (CXMLReg &xmlFile, HKEY hCurrentKey)
LONG ImportHelper (CXMLReg &xmlFile, HKEY hCurrentKey)
LONG ReplicateHelper (HKEY hParentKey, HKEY hCopyFromParentKey)
LONG GetStrInternal (HKEY hKey, LPCTSTR string, std::wstring &lpszData, FetchType type)
LONG GetDwordInternal (HKEY hKey, LPCTSTR string, DWORD &dwWord)

Protected Attributes

CAtlString BasePath
HKEY m_hIp
CXMLReg * m_xmlExportFile
CXMLReg * m_xmlImportFile


Member Enumeration Documentation

enum DFRegTool::FetchType [protected]
 

Enumeration values:
Readable 
Encoded 
Whole 


Constructor & Destructor Documentation

DFRegTool::DFRegTool  ) 
 

virtual DFRegTool::~DFRegTool  )  [virtual]
 


Member Function Documentation

LONG DFRegTool::OpenKey  ) 
 

LONG DFRegTool::OpenKey const CAtlString &   ) 
 

LONG DFRegTool::OpenKey const std::wstring &   ) 
 

LONG DFRegTool::OpenKey const TCHAR *   ) 
 

LONG DFRegTool::OpenKey DWORD &   ) 
 

LONG DFRegTool::OpenKey const CAtlString &  ,
DWORD & 
 

LONG DFRegTool::OpenKey const std::wstring &  ,
DWORD & 
 

LONG DFRegTool::OpenKey const TCHAR *  ,
DWORD & 
 

LONG DFRegTool::CloseKey  ) 
 

LONG DFRegTool::AddDword LPCTSTR  key,
DWORD  value
 

LONG DFRegTool::GetDword LPCTSTR  key,
DWORD &  value
 

Retrieves the DWORD value for a specified key in the registry.

Parameters:
key The key, in relation to the opened location, who's calue you are attempting to retrieve.
value The variable to insert the value associated with the specified key.
Returns:
The success value specified by the Windows registry API for fetching the value.

LONG DFRegTool::GetDword LPCTSTR  key,
int &  value
 

LONG DFRegTool::GetDword LPCTSTR  key,
bool &  value
 

LONG DFRegTool::AddStr LPCTSTR  key,
LPCTSTR  value
 

LONG DFRegTool::AddStr LPCTSTR  key,
const CAtlString &  value
 

LONG DFRegTool::AddStr LPCTSTR  key,
const std::wstring &  value
 

LONG DFRegTool::GetStr LPCTSTR  key,
LPTSTR  ,
DWORD  value
 

LONG DFRegTool::GetStr LPCTSTR  key,
CAtlString &  value
 

LONG DFRegTool::GetStr LPCTSTR  key,
std::wstring &  value
 

LONG DFRegTool::AddCodedStr LPCTSTR  key,
const CAtlString &  value,
int  codeA,
int  codeB
 

LONG DFRegTool::AddCodedStr LPCTSTR  key,
const std::wstring &  value,
int  codeA,
int  codeB
 

LONG DFRegTool::AddCodedStr LPCTSTR  key,
const TCHAR *  value,
int  codeA,
int  codeB
 

LONG DFRegTool::GetCodedStr LPCTSTR  key,
CAtlString &  value,
int  codeA,
int  codeB
 

LONG DFRegTool::GetCodedStr LPCTSTR  key,
std::wstring &  value,
int  codeA,
int  codeB
 

LONG DFRegTool::DeleteContents  ) 
 

LONG DFRegTool::DeleteFolder LPCTSTR   ) 
 

LONG DFRegTool::DeleteKey LPCTSTR   ) 
 

LONG DFRegTool::Replicate const DFRegTool  ) 
 

LONG DFRegTool::NextKey CAtlString &  strFileName,
int  iSetBack = 0
 

LONG DFRegTool::NextKey std::wstring &  strFileName,
int  iSetBack = 0
 

LONG DFRegTool::NextValue CAtlString &  strValueName,
int  iSetBack = 0
 

LONG DFRegTool::NextValue std::wstring &  strValueName,
int  iSetBack = 0
 

LONG DFRegTool::BeginExportToXML  ) 
 

LONG DFRegTool::ExportKeyToXML LPCTSTR  szKeyName,
DFRegTool regKey
 

LONG DFRegTool::EndExportToXML LPCTSTR  szFileName  ) 
 

LONG DFRegTool::BeginImportFromXML LPCTSTR  szFileName  ) 
 

LONG DFRegTool::ImportFromXML LPCTSTR  szKeyName,
CXMLReg &  xmlImport
 

LONG DFRegTool::EndImportFromXML  ) 
 

CXMLReg* DFRegTool::GetXMLImporter  ) 
 

CXMLReg* DFRegTool::GetXMLExporter  ) 
 

LONG DFRegTool::DeleteHelper HKEY  hParentKey  )  [protected]
 

LONG DFRegTool::ExportHelper CXMLReg &  xmlFile,
HKEY  hCurrentKey
[protected]
 

LONG DFRegTool::ImportHelper CXMLReg &  xmlFile,
HKEY  hCurrentKey
[protected]
 

LONG DFRegTool::ReplicateHelper HKEY  hParentKey,
HKEY  hCopyFromParentKey
[protected]
 

LONG DFRegTool::GetStrInternal HKEY  hKey,
LPCTSTR  string,
std::wstring &  lpszData,
FetchType  type
[protected]
 

LONG DFRegTool::GetDwordInternal HKEY  hKey,
LPCTSTR  string,
DWORD &  dwWord
[protected]
 


Member Data Documentation

CAtlString DFRegTool::BasePath [protected]
 

HKEY DFRegTool::m_hIp [protected]
 

CXMLReg* DFRegTool::m_xmlExportFile [protected]
 

CXMLReg* DFRegTool::m_xmlImportFile [protected]
 


The documentation for this class was generated from the following file:

Copyright (c) 2003-2004, Deep Fried Software. All rights reserved.